import request from '@/utils/request.js'
/**
 * 根据频道id和时间戳获取文章列表
 * @param {*} channelId 频道编号
 * @param {*} timestamp 时间戳
 */
export const getArticles = (channelId, timestamp) => {
  return request({
    method: 'GET',
    url: 'v1_0/articles',
    params: {
      channel_id: channelId,
      timestamp // 时间戳，请求新的推荐数据传当前的时间戳，请求历史推荐传指定的时间戳
    }
  })
}

// 不感兴趣的文章
export const disLike = articleId => {
  return request({
    method: 'POST',
    url: '/v1_0/article/dislikes',
    data: {
      target: articleId
    }
  })
}

// 举报文章
export const report = (articleId, type) => {
  return request({
    method: 'POST',
    url: '/v1_0/article/reports',
    data: {
      target: articleId,
      type
    }
  })
}

// 举报文章（其它问题）
export const otherReport = (articleId, type, remark) => {
  return request({
    method: 'POST',
    url: '/v1_0/article/reports',
    data: {
      target: articleId,
      type,
      remark
    }
  })
}

/**
 * 获取文章详情
 * @param {*} articleId
 */
export const getDetail = articleId => {
  return request({
    method: 'GET',
    url: '/v1_0/articles/' + articleId
  })
}

/**
 * 取消点赞
 * @param {*} id 文章编号
 */
export const deleteLike = id => {
  return request({
    method: 'DELETE',
    url: '/v1_0/article/likings/' + id
  })
}

/**
 * 添加点赞
 * @param {*} id 文章编号
 */
export const addLike = id => {
  return request({
    method: 'POST',
    url: '/v1_0/article/likings',
    data: {
      target: id
    }
  })
}

